"use strict";

angular.module("app").controller("searchCtrl", ["dict", "$scope", "$http", function(dict, $scope, $http){
//	cache.put("abc", "dfg");
	$scope.name = "";
	var tableId = "";
	$scope.filterObj = {};
	$scope.search = function(){
		$http.get("/data/positionList.json?name="+$scope.name).then(function(resp){
			console.log(resp);
			$scope.list = resp.data;
		});
	};
	$scope.search();
	$scope.tabList = [{
		id: "city",
		name: "城市",
	},{
		id: "salary",
		name: "薪水",
	},{
		id: "scale",
		name: "公司规模",
	}];
	$scope.tClick= function(id, name){
//		console.log(id, name);
		tableId = id;
		$scope.sheetList = dict[id];
		$scope.sheetVisible = true;
	};
	$scope.sClick= function(id, name){
//		console.log(id, name);
		if(id){
			angular.forEach($scope.tabList, function(item){
				if(item.id === tableId){
					item.name = name;
				}
			});
			$scope.filterObj[tableId + "Id"] = id;
		}else{
			delete $scope.filterObj[tableId + "Id"];
			angular.forEach($scope.tabList, function(item){
				if(item.id === tableId){
					switch(item.id){
						case "city":
							item.name = "城市";
							break;
						case "salary":
							item.name = "薪资";
							break;
						case "scale":
							item.name = "公司规模";
							break;
					}
				}
			});
		}
	}
	
}]);
